﻿using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using GMS.BLL;
using GMS.Model;
using GMS.Utils;
using Maticsoft.DBUtility;
//using DL.GSTAPlan.Utils.ServiceContext;
//using EmailTool;

public partial class Public_UserEdit : System.Web.UI.Page
{
    //UserAccessBLL userAccessBll = new UserAccessBLL();
    //UserBLL userBll = new UserBLL();

    //UserRoleAccessBLL userRoleAccessBll = new UserRoleAccessBLL();
    //UserRoleBLL userRoleBll = new UserRoleBLL();
    //OperationPrincipal OP = new OperationPrincipal();
    //CityOrderBLL cityManager = new CityOrderBLL();
    //CityBLL citybll = new CityBLL();
    //RoleCityRightBll roleCitybll = new RoleCityRightBll();
    MD5 md5 = new MD5();
    List<UserRole> dicUserRole;
    User user;
    //AddressListBLL addrbll = new AddressListBLL();
    //AddressList addrmodel;

    static DataTable DtInfo;
    static string rybh;

    string sComPassword = "123456";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["UserId"] == null)
            {
                Response.Write("<script>alert('登陆已过期，请重新登陆！');top.location.href='" + Request.ApplicationPath + "/Login.aspx';</script>");
                return;
            }
            //OP = (OperationPrincipal)Session["OperationPrincipal"];
            //if (Session["_UserInfo"] == null || OP ==null)
            //{
            //    Response.Write("<script>alert('登陆已过期，请重新登陆！');top.location.href='" + Request.ApplicationPath + "/Login.aspx';</script>");
            //    return;
            //}
            //DtInfo = (DataTable)Session["_UserInfo"];
           // rybh = DtInfo.Rows[0]["USERACCOUNT"].ToString();

            if (!IsPostBack)
            {
                Response.Expires = -1;
                //txSpecRole.Visible = false;
                string getAccount = Request.QueryString["Acount"];
                if (getAccount == "undefined")//undefined表示新建，不用显示用户信息
                {
                    ViewState["Acount"] = "";
                    TextBox1.Text = "1";
                    lbnewpwd.Visible = true;
                    lbnewpwd2.Visible = true;
                    btnBack.Visible = true;
                }
                else
                {
                    //为空、不存在 或者为LoginAccount 时 表示显示当前登录用户
                    if (string.IsNullOrEmpty(getAccount) || getAccount.Equals("LoginAccount"))
                    {
                        ViewState["Acount"] = Session["UserId"].ToString();
                        DDLUserRole.Enabled = false;
                        //ddlCompany.Enabled = false;
                        //TxtDepartment.Enabled = false;
                        btnBack.Visible = false;
                        P_LockInfo.Visible = false;
                        P_ToSendEmail.Visible = false;
                    }
                    else
                    {
                        //表示修改、查看传过来的用户
                        ViewState["Acount"] = Request.QueryString["Acount"];
                        TextBox1.Text = "2";
                        lbnewpwd.Visible = false;
                        lbnewpwd2.Visible = false;
                        btnBack.Visible = true;
                    }
                }

                //EnumHelper.E_DefaultSendEmail defaultEmail = (EnumHelper.E_DefaultSendEmail)Enum.Parse(typeof(EnumHelper.E_DefaultSendEmail), SysEnvirConfigBLL.GetDefaultSendEmail());
                //string l_defaultmail = " *默认发送邮箱";
                //switch (defaultEmail)
                //{
                //    case EnumHelper.E_DefaultSendEmail.EMAILBYOA:
                //        L_DefaultOA.Text = l_defaultmail;
                //        break;
                //    case EnumHelper.E_DefaultSendEmail.EMIALBY189:
                //        L_Default189.Text = l_defaultmail;
                //        break;
                //    case EnumHelper.E_DefaultSendEmail.EMAILBYTHIRD:
                //        L_DefaultThird.Text = l_defaultmail;
                //        break;
                //    default:
                //        L_DefaultOA.Text = l_defaultmail;
                //        break;
                //}
                PgLoad();
            }
            //if (ddlCompany.SelectedValue.ToString()=="-1")
            //{
            //    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>DisSpecRole()</script>");
            //}
        }
        catch
        {
            Response.Write("<script>alert('读取数据错误！');window.location.href='UserManager.aspx';</script>");
        }
    }
    public void PgLoad()
    {
        int ddlSelectIndex=0;
        string sPwd = string.Empty;
        string sCity = string.Empty;
        //绑定角色列表
        DDLUserRole.Items.Clear();
        ListItem item = new ListItem("--请选择--", "-1");
        DDLUserRole.Items.Add(item);
        //ddlCompany.Items.Clear();
        ddlDepartment.Items.Clear();
        item = new ListItem("--自定义--", "-1");
        ddlDepartment.Items.Add(item);


        DataTable existsDetpDt = null;
        if ((int)EnumHelper.E_DbType.DB_ACCESS == PubConstant.GetDBType())
        {
            UserRoleAccessBLL userRoleAccessBll = new UserRoleAccessBLL();
            dicUserRole = userRoleAccessBll.GetModelList("");
            UserAccessBLL userAccessBll = new UserAccessBLL();
            existsDetpDt = userAccessBll.GetExistsDeptList();
        }
        else if ((int)EnumHelper.E_DbType.DB_SQL == PubConstant.GetDBType())
        {
            UserRoleBLL userRoleBll = new UserRoleBLL();
            dicUserRole = userRoleBll.GetModelList("");
            UserBLL userBll = new UserBLL();
            existsDetpDt = userBll.GetExistsDeptList();
        }
        else if ((int)EnumHelper.E_DbType.DB_ORACLE == PubConstant.GetDBType())
            return;//
        else
            return;

        
        foreach(UserRole model in dicUserRole)
        {
            item = new ListItem(model.USERROLENAME,model.TABUSERROLECODE.ToString());          
            item.Attributes.Add("title", model.USERROLENAME);
            DDLUserRole.Items.Add(item);
        }

        
        if (existsDetpDt != null)
        {
            for (int i = 0; i < existsDetpDt.Rows.Count; i++)
            {
                item = new ListItem(existsDetpDt.Rows[i]["DEPARTMENT"].ToString(), existsDetpDt.Rows[i]["DEPARTMENT"].ToString());
                item.Attributes.Add("title", existsDetpDt.Rows[i]["DEPARTMENT"].ToString());
                ddlDepartment.Items.Add(item);
            }
        }

        this.TxtNewPwd.TextMode = TextBoxMode.Password;

        //if (ViewState["Acount"].ToString().Equals(""))
        if (ViewState["Acount"] == null || ViewState["Acount"].ToString().Equals(""))
        {
            this.TxtNewPwd.Attributes["Value"] = sComPassword;
            this.TxtNewPwd2.Attributes["Value"] = sComPassword;
            //ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>DisSpecRole()</script>");
            //TxtNewPwd.Attributes.Add("value", "123456");
        }
        else
        {
            if ((int)EnumHelper.E_DbType.DB_ACCESS == PubConstant.GetDBType())
            {
                UserAccessBLL userAccessBll = new UserAccessBLL();
                user = userAccessBll.GetModel(ViewState["Acount"].ToString());
            }
            else if ((int)EnumHelper.E_DbType.DB_SQL == PubConstant.GetDBType())
            {
                UserBLL userBll = new UserBLL();
                user = userBll.GetModel(ViewState["Acount"].ToString());
            }
            else if ((int)EnumHelper.E_DbType.DB_ORACLE == PubConstant.GetDBType())
                return;//
            else
                return;
            
            //addrmodel = addrbll.GetModelByAccount(ViewState["Acount"].ToString());
            //sCity = user.ISCITY;
            //txSpecRole.Value = user.Company;
            TxtAcount.Value = user.UserAccount;
            TxtAcount.Disabled = true;
            TxtUserName.Text = user.UserName;
            sPwd = md5.DecryptString(user.Pwd, user.PwdKey);
            this.TxtNewPwd.Attributes["Value"] = sPwd;
            this.TxtNewPwd2.Attributes["Value"] = sPwd;   
            
            TxtDepartment.Value = user.Department;
            if (user.Status.ToString().Equals("1"))
                DDLIsLock.SelectedIndex = 1;
            if (user.IsCsAdmin.Equals("1"))
                DDLIsCsAdmin.SelectedIndex = 1;
            TxtCreator.Text = user.Creator;
            TxtCreateTime.Text = user.CreateDT.ToString();
            TxtUpdater.Text = user.Updator;
            TxtUpdateTime.Text = user.UpdateDT.ToString();
            TxtLastIp.Text = user.LastDT.ToString(); ;
            TxtPwdHint.Text = user.PwdHint.ToString();
            for (int i = 0; i < DDLUserRole.Items.Count; i++)
            {
                if (int.Parse(DDLUserRole.Items[i].Value) == user.TabUserRoleCode)
                {
                    DDLUserRole.Items[i].Selected = true;
                    break;
                }
            }
            for (int i = 0; i < ddlDepartment.Items.Count; i++)
            {
                if (ddlDepartment.Items[i].Value == user.Department)
                {
                    ddlDepartment.Items[i].Selected = true;
                    break;
                }
            }
            //如何用户存在通讯录信息
            //if (addrmodel != null)
            //{
            //    TB_DUTY.Text = addrmodel.DUTY;
            //    TB_WORKPHONE.Text = addrmodel.WORKPHONE;
            //    TB_MOBILE.Text = addrmodel.MOBILE;
            //    TB_EMAILBYOA.Text = addrmodel.EMAILBYOA;
            //    TB_EMAILBY189.Text = addrmodel.EMAILBY189;
            //    TB_EMAILTHIRD.Text = addrmodel.EMAILBYTHIRD;
            //    DDL_FLAG.SelectedValue = addrmodel.FLAG;
            //}
        }
        //aiks 20091007 
        //List<DL.GSTAPlan.Model.CityOrder> ModuleList = cityManager.GetModelList("");
        //DL.GSTAPlan.Model.CityOrder co = cityManager.GetModel(DateTime.Now.Year.ToString());
        //如果用户是特殊角色,去掉自定义项
        //List<DL.GSTAPlan.Model.CitySeq> csList;
        //if (user == null || roleCitybll.IsSpecialRoleCity(user.TabUserRoleCode))
        //    csList = OP.AllCityList;//co.CITYSEQ;
        //else
        //    csList = citybll.GetSpecialCityList();
        //for (int i = 0; i < csList.Count; i++)
        //{
        //    item = new ListItem(csList[i].cityname, csList[i].citycode.ToString());
        //    item.Attributes.Add("title", csList[i].cityname);
        //    ddlCompany.Items.Add(item);
        //    if (user != null && csList[i].cityname.ToString().Equals(user.Company))
        //    {
        //        ddlCompany.Items[i].Selected = true;
        //    }
        //}
        //if (sCity == "-1")
        //{
        //    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>DisSpecRole()</script>");
        //}
        if (ddlDepartment.SelectedValue.Equals("-1"))
            TxtDepartment.Style.Value = "display:online";
    }

    protected void DDLUserRole_IndexChanged(object sender, EventArgs e)
    {
        //string CompanySelectedValue = ddlCompany.SelectedValue;
        //ddlCompany.Items.Clear();
        ListItem item;
        //List<DL.GSTAPlan.Model.CitySeq> csList;
        //if (!roleCitybll.IsSpecialRoleCity(DDLUserRole.SelectedValue))
        //{
        //    csList = citybll.GetSpecialCityList();
        //}
        //else
        //{
        //    csList = OP.AllCityList;//co.CITYSEQ;
        //    this.Page.RegisterStartupScript("", "<script>SelSpecRole('1','txSpecRole')</script>");
        //}
        //for (int i = 0; i < csList.Count; i++)
        //{
        //    item = new ListItem(csList[i].cityname, csList[i].citycode.ToString());
        //    ddlCompany.Items.Add(item);
        //}
        //if (CompanySelectedValue != "-1")
        //{
        //    for (int i = 0; i < ddlCompany.Items.Count; i++)
        //    {
        //        if (ddlCompany.Items[i].Value == CompanySelectedValue)
        //        {
        //            ddlCompany.Items[i].Selected = true;
        //            break;
        //        }
        //    }
        //}
        //if (ddlCompany.SelectedValue.Equals("-1"))
        //    txSpecRole.Style.Value = "display:online";
    }

    protected void BtnExsit_Click(object sender, EventArgs e)
    {
        if (!TxtAcount.Value.Trim().Equals(""))
        {
            bool isExist = true;
            if ((int)EnumHelper.E_DbType.DB_ACCESS == PubConstant.GetDBType())
            {
                isExist = new UserAccessBLL().Exists(TxtAcount.Value.Trim().ToUpper());
            }
            else if ((int)EnumHelper.E_DbType.DB_SQL == PubConstant.GetDBType())
            {
                isExist = new UserBLL().Exists(TxtAcount.Value.Trim().ToUpper());
            }
            else if ((int)EnumHelper.E_DbType.DB_ORACLE == PubConstant.GetDBType())
                return;//
            else
                return;
            if (isExist)
            {
                LblAcount.Text = "该用户账号已存在，请输入别的账号！";
                TxtAcount.Value = "";
            }
            else
            {
                LblAcount.Text = "恭喜你，该账号可用！";
            }
        }
        else
            LblAcount.Text = "";
    }

    protected void BtnUpdateData_Click(object sender, EventArgs e)
    {

    }
     
    protected void BtnInsertData_Click(object sender, EventArgs e)
    {
        this.Page.RegisterClientScriptBlock("", "<script>alert('插入');</script>");
    }
    protected void BtnUpdate_ServerClick(object sender, EventArgs e)
    {
        bool addrExists = true;
        int iNum = 0;
        int addrid = -1;
        int iAction = 0;
        string sMesg = string.Empty;
        string sKey = string.Empty;
        string OpAccount = string.Empty;
        OpAccount = (string)Session["UserID"];
        try
        {
            if ((TxtAcount.Value.Trim().Length <= 0) || (TxtUserName.Text.Trim().Length <= 0) || (DDLUserRole.SelectedValue.Equals("-1")) 
                || LblAcount.Text.IndexOf("该用户账号已存在") >= 0)
            {
                sMesg = "信息不完整或用户帐号无效！";
                this.Page.RegisterClientScriptBlock("", "<script>alert('" + sMesg + "');</script>");
                return;
            }

            string passAccount = Request.QueryString["Acount"];
            //当前面页面传过来为null或者为undefined时，说明是新建一个用户，否则需要查询数据库里面的用户信息
            if (passAccount != null && passAccount != "undefined")
            {
                iAction = 1;
                if ((int)EnumHelper.E_DbType.DB_ACCESS == PubConstant.GetDBType())
                    user = new UserAccessBLL().GetModel(ViewState["Acount"].ToString());
                else if ((int)EnumHelper.E_DbType.DB_SQL == PubConstant.GetDBType())
                    user = new UserBLL().GetModel(ViewState["Acount"].ToString());
                else if ((int)EnumHelper.E_DbType.DB_ORACLE == PubConstant.GetDBType())
                    return;//
                else
                    return;
               
                user.UserAccount = ViewState["Acount"].ToString();
                //addrmodel = addrbll.GetModelByAccount(ViewState["Acount"].ToString());
                //if (addrmodel == null)
                //{
                //    addrmodel = new AddressList();
                //    addrExists = false;
                //}
                //addrmodel.UserAccount = ViewState["Acount"].ToString();
            }
            else
            {
                user = new User();
                //addrmodel = new AddressList();
                iAction = 0;
                user.UserAccount = Request.Form["TxtAcount"].ToString();
                //addrmodel.UserAccount = Request.Form["TxtAcount"].ToString();
            }
            user.TabUserRoleCode = int.Parse(DDLUserRole.SelectedValue.ToString());

            //这2个name有啥区别？现在暂时一样
            user.UserName = TxtUserName.Text.ToString();
            user.RealName = TxtUserName.Text.ToString();
            user.Department = ddlDepartment.SelectedValue.Equals("-1") ? TxtDepartment.Value : ddlDepartment.SelectedValue;
            //if (roleCitybll.IsSpecialRoleCity(DDLUserRole.SelectedValue))
            //{
            //    user.Company = ddlCompany.SelectedValue;
            //    user.ISCITY = "1";
            //}
            //else
            //{
            //    user.Company = ddlCompany.SelectedValue != "-1" ? ddlCompany.SelectedValue : txSpecRole.Value.ToString();
            //    user.ISCITY = "0";
            //}
            if (DDLIsLock.SelectedValue.ToString() == "1")
                user.Status = 1;
            else
                user.Status = 0;
            if (DDLIsCsAdmin.SelectedValue.ToString() == "1")
                user.IsCsAdmin = "1";
            else
                user.IsCsAdmin = "0";
            user.Updator = OpAccount;
            user.UpdateDT = System.DateTime.Now;

            string userPassword = null;
            if ((TxtNewPwd.Text.Length <= 0) || (TxtNewPwd2.Text.Length <= 0) || (this.TxtNewPwd.Text.ToString() != this.TxtNewPwd2.Text.ToString()))
            {
                sMesg = "密码不能为空且必须一致！";
                this.Page.RegisterClientScriptBlock("", "<script>alert('" + sMesg + "');</script>");
                return;
            }
            //if ((Request.Form["TxtNewPwd2"] != null) && (Request.Form["TxtNewPwd2"].Length > 0))
            //当用户实例的密码值为空,或者不为空且该值与密码文本框的值不一致,重新设置密码及密钥
            else if (user.Pwd == null || (user.Pwd != null && user.PwdKey != null && !md5.EncryptString(this.TxtNewPwd2.Text, user.PwdKey).Equals(user.Pwd)))
            {
                userPassword = this.TxtNewPwd2.Text;
                sKey = md5.GenerateKey();
                user.Pwd = md5.EncryptString(this.TxtNewPwd2.Text, sKey);
                user.PwdKey = sKey;
            }

            user.PwdHint = Request.Form["TxtPwdHint"].ToString();
            user.Attribute1 = "";
            user.Attribute2 = "";
            user.Attribute3 = "";
            user.Attribute4 = "";
            user.LastDT = System.DateTime.Now;
            user.LastIp = "";
            //user.PwdValidDate = ;
            user.TabUserRoleCode = int.Parse(this.DDLUserRole.Text.ToString());

            //设置通讯录信息
            if (TB_EMAILBYOA.Text != "")
                if (!comUse.IsEmail(TB_EMAILBYOA.Text))
                {
                    this.Page.RegisterClientScriptBlock("", "<script>alert('OA邮箱无效');</script>");
                    return;
                }
            if (TB_EMAILBY189.Text != "")
                if (!comUse.IsEmail(TB_EMAILBY189.Text))
                {
                    this.Page.RegisterClientScriptBlock("", "<script>alert('189邮箱无效');</script>");
                    return;
                }
            if (TB_EMAILTHIRD.Text != "")
                if (!comUse.IsEmail(TB_EMAILTHIRD.Text))
                {
                    this.Page.RegisterClientScriptBlock("", "<script>alert('第三方邮箱无效');</script>");
                    return;
                }
            if (CB_ToSendEmail.Checked == true && TB_EMAILBYOA.Text == "" && TB_EMAILBY189.Text == "" && TB_EMAILTHIRD.Text == "")
            {
                this.Page.RegisterClientScriptBlock("", "<script>alert('您选发了发送帐号信息,最少需要提供一个发送邮件的邮箱!');</script>");
                return;
            }
            //addrmodel.NAME = TxtUserName.Text;
            //addrmodel.COMPANY = ddlCompany.SelectedValue == "-1" ? txSpecRole.Value : ddlCompany.SelectedItem.Text;
            //addrmodel.DEPT = TxtDepartment.Value;
            //addrmodel.DUTY = TB_DUTY.Text;
            //addrmodel.WORKPHONE = TB_WORKPHONE.Text;
            //addrmodel.MOBILE = TB_MOBILE.Text;
            //addrmodel.EMAILBYOA = TB_EMAILBYOA.Text;
            //addrmodel.EMAILBY189 = TB_EMAILBY189.Text;
            //addrmodel.EMAILBYTHIRD = TB_EMAILTHIRD.Text;
            //addrmodel.FLAG = DDL_FLAG.SelectedValue;
            //if(addrmodel.CREATOR ==null)
            //    addrmodel.CREATOR = rybh;
            //addrmodel.UPDATOR = rybh;
            //addrmodel.UPDATEDT = DateTime.Now;

            //string sendEmail = StringHelper.GetDefaultNotNullEmail(SysEnvirConfigBLL.GetDefaultSendEmail(), TB_EMAILBYOA.Text, TB_EMAILBY189.Text, TB_EMAILTHIRD.Text);
            if (iAction == 0)
            {
                if ((user.Pwd == null) || (user.Pwd.Length <= 0))
                {
                    sMesg = "密码不能为空";
                    iNum = 0;
                }
                else
                {
                    //addrmodel.CREATOR = rybh;
                    //addrmodel.CREATEDT = DateTime.Now;
                    //addrid = addrbll.Add(addrmodel);

                    user.CreateDT = System.DateTime.Now;
                    user.Creator = OpAccount;
                    
                    if ((int)EnumHelper.E_DbType.DB_ACCESS == PubConstant.GetDBType())
                        new UserAccessBLL().Add(user);
                    else if ((int)EnumHelper.E_DbType.DB_SQL == PubConstant.GetDBType())
                        new UserBLL().Add(user);
                    else if ((int)EnumHelper.E_DbType.DB_ORACLE == PubConstant.GetDBType())
                        return;//
                    else
                        return;
                    //Dvbbs.bbs.Handlers.UserHandler.AutoUpdateUser(user.UserAccount, userPassword, sendEmail, user.Status == 1, false);

                    sMesg = "新建成功";
                    if (CB_ToSendEmail.Checked == true) ToSendAccountEmail();
                }
            }
            else
            {
                if ((int)EnumHelper.E_DbType.DB_ACCESS == PubConstant.GetDBType())
                    new UserAccessBLL().Update(user);
                else if ((int)EnumHelper.E_DbType.DB_SQL == PubConstant.GetDBType())
                    new UserBLL().Update(user);
                else if ((int)EnumHelper.E_DbType.DB_ORACLE == PubConstant.GetDBType())
                    return;//
                else
                    return;
                
                //Dvbbs.bbs.Handlers.UserHandler.AutoUpdateUser(user.UserAccount, userPassword, sendEmail, user.Status == 1, false);

                sMesg = "修改成功";
                //if (addrExists)
                //    addrbll.Update(addrmodel);
                //else
                //    addrbll.Add(addrmodel);
                //if (CB_ToSendEmail.Checked == true) ToSendAccountEmail();
            }
            if (Request.QueryString["Acount"] == "LoginAccount")
                this.Page.RegisterClientScriptBlock("", "<script>alert('" + sMesg + "');</script>");
            else
                this.Page.RegisterClientScriptBlock("", "<script>alert('" + sMesg + "');window.location.href='UserManager.aspx';</script>");
        }
        catch(Exception ex)
        {
            //if(iAction == 0)
            //    addrbll.Delete(addrid);

            sMesg = "操作失败";
            this.Page.RegisterClientScriptBlock("", "<script>alert('" + sMesg + ex.Message.Replace('\'', ' ').Replace("\n", "").Replace("\r", "") + "');</script>");
        }
    }

    protected void ToSendAccountEmail()
    {
        //Mail email = new Mail();
        //email.Sendfrom = System.Configuration.ConfigurationSettings.AppSettings["MailFrom"];    //或此处取登陆人的联系方式中的邮箱
        //email.Sendto = StringHelper.GetDefaultNotNullEmail(SysEnvirConfigBLL.GetDefaultSendEmail(), TB_EMAILBYOA.Text, TB_EMAILBY189.Text, TB_EMAILTHIRD.Text);
        //email.Subject = "网优系统帐号信息";
        //email.Content = "系统路径:" + SysEnvirConfigBLL.GetValue("系统路径") + "\n用户名:" + TxtAcount.Value + "\n密码：" + TxtNewPwd.Text;
        //SMTPServer smtpServer = new SMTPServer();
        //DL.GSTAPlan.Model.MailPlanConfig c = new DL.GSTAPlan.DAL.MailPlanConfigDAL().GetModel();
        //smtpServer.Ip = c.SmtpHost;
        //smtpServer.Port = Convert.ToInt32(c.SmtpPort);
        //smtpServer.Account = c.SmtpUser;
        //smtpServer.Password = c.SmtpPassword;
        //smtpServer.RequireAuthorized = bool.Parse(c.SmtpAuth); 

        //EmailTool.HandleEmail.SendMail(email, smtpServer);
    }

    protected void btnBack_ServerClick(object sender, EventArgs e)
    {
        this.Response.Redirect("UserManager.aspx");
    }
}
